package com.changgou.goods.handler;

import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author: HuangFu
 * @Date: 2020/1/15 16:17
 * @Description: 统一异处理器
 */

@ControllerAdvice //声明增强类
public class BaseExceptionHandler {

    /**
     * 异常响应类
     * @param e
     * @return
     */
    @ExceptionHandler
    @ResponseBody
    public Result error(Exception e){
        e.printStackTrace();
        return new Result(false, StatusCode.ERROR,"系统访问繁忙，请稍后再试");
    }
}
